<?php
/**
 * Created by PhpStorm.
 * User=> Administrator
 * Date=> 2021/3/25 0025
 * Time=> 下午 4=>23
 */

namespace app\api\controller;


use think\Controller;
use think\facade\Session;

class Menu extends Controller
{
    public function data()
    {


        $data = [
            [
                "id" => "component",
                "title" => "新闻管理",
                "icon" => "layui-icon layui-icon-component",
                "type" => 0,
                "href" => "",
                "children" => [[
                    "id" => 12,
                    "title" => "查看新闻",
                    "icon" => "layui-icon",
                    "type" => 1,
                    "openType" => "_iframe",
                    "href" => "http://www.yd2021.com/admin/article/index"
                ], [
                    "id" => 13,
                    "title" => "添加新闻",
                    "icon" => "layui-icon",
                    "type" => 1,
                    "openType" => "_iframe",
                    "href" => "http://www.yd2021.com/admin/article/add"
                ], [
                    "id" => 14,
                    "title" => "百度一下",
                    "icon" => "",
                    "type" => 1,
                    "openType" => "_iframe",
                    "href" => "http://www.baidu.com"
                ]]
            ],
            [
                "id" => "component",
                "title" => "轮播图管理",
                "icon" => "layui-icon layui-icon-carousel",
                "type" => 0,
                "href" => "",
                "children" => [[
                    "id" => 2011,
                    "title" => "查看轮播图",
                    "icon" => "layui-icon layui-icon-face-smile",
                    "type" => 1,
                    "openType" => "_iframe",
                    "href" => "http://www.yd2021.com/admin/banner/index"
                ]]
            ],

        ];
        $userData = Session::get("userData");

        if (in_array($userData["username"],["admin","root"])) {
            $data[] = [
                    "id" => "system",
                    "title" => "权限管理",
                    "icon" => "layui-icon layui-icon-username",
                    "type" => 0,
                    "href" => "",
                    "children" => [[
                        "id" => 601,
                        "title" => "用户管理",
                        "icon" => "layui-icon layui-icon-face-smile",
                        "type" => 1,
                        "openType" => "_iframe",
                        "href" => "http://www.yd2021.com/admin/user/index"
                    ]]
                ];
        };



        return json($data);
    }
}